<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>用户添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入昵称" class="layui-input"
                   id="nickname">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入头像" class="layui-input"
                   id="headPhoto">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">token</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入token" class="layui-input"
                   id="token">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">0正常 -1冻结 -10删除</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入0正常 -1冻结 -10删除" class="layui-input"
                   id="status">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色 1管理 2基层 3咨询师</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入角色 1管理 2基层 3咨询师" class="layui-input"
                   id="role">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开启任务树1 关闭0</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入开启任务树1 关闭0" class="layui-input"
                   id="openTree">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="number" placeholder="请输入手机号码" class="layui-input"
                   id="phone">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">在职1 离职0</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入在职1 离职0" class="layui-input"
                   id="isJob">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">医院id</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入医院id" class="layui-input"
                   id="btvId">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属科室</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入所属科室" class="layui-input"
                   id="btvOrgId">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入备注" class="layui-input"
                   id="memo">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职位</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入职位" class="layui-input"
                   id="position">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <a class="layui-btn layui-btn-normal" lay-filter="demo1" id="add">立即提交</a>
            <a class="layui-btn layui-btn-primary close">取消</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script>


    layui.use(['form'], function () {
    });


    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    $("#add").click(function () {

        if ($("#nickname").val() == "") {
            layer.msg('请输入昵称', {icon: 2});
            return;
        }
        if ($("#headPhoto").val() == "") {
            layer.msg('请输入头像', {icon: 2});
            return;
        }
        if ($("#token").val() == "") {
            layer.msg('请输入token', {icon: 2});
            return;
        }
        if ($("#status").val() == "") {
            layer.msg('请输入0正常 -1冻结 -10删除', {icon: 2});
            return;
        }
        if ($("#role").val() == "") {
            layer.msg('请输入角色 1管理 2基层 3咨询师', {icon: 2});
            return;
        }
        if ($("#openTree").val() == "") {
            layer.msg('请输入开启任务树1 关闭0', {icon: 2});
            return;
        }
        if ($("#phone").val() == "") {
            layer.msg('请输入手机号码', {icon: 2});
            return;
        }
        if ($("#isJob").val() == "") {
            layer.msg('请输入在职1 离职0', {icon: 2});
            return;
        }
        if ($("#btvId").val() == "") {
            layer.msg('请输入医院id', {icon: 2});
            return;
        }
        if ($("#btvOrgId").val() == "") {
            layer.msg('请输入所属科室', {icon: 2});
            return;
        }
        if ($("#memo").val() == "") {
            layer.msg('请输入备注', {icon: 2});
            return;
        }
        if ($("#position").val() == "") {
            layer.msg('请输入职位', {icon: 2});
            return;
        }

        $.ajax({
            type: "post",
            url: "/user/save",
            data: {
                nickname: $("#nickname").val(),
                headPhoto: $("#headPhoto").val(),
                token: $("#token").val(),
                status: $("#status").val(),
                role: $("#role").val(),
                openTree: $("#openTree").val(),
                phone: $("#phone").val(),
                isJob: $("#isJob").val(),
                btvId: $("#btvId").val(),
                btvOrgId: $("#btvOrgId").val(),
                memo: $("#memo").val(),
                position: $("#position").val(),
                extra:
                    1
            },
            dataType: "json",
            success:

                function (data) {
                    if (data.status == 0) {
                        var index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
                        setTimeout(function () {
                            layer.closeAll("iframe");
                            top.layer.msg("添加成功！");
                            //刷新父页面
                            parent.getList({});
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }, 500);
                    } else {
                        layer.msg(data.msg, {icon: 1});
                    }
                }
        })
        ;
    });


    $(document).ready(function () {

    });

</script>
</body>

</html>